package com.yegs.jindie.entity;


import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

@Entity
public class LoggerVo implements Serializable {

    public LoggerVo() {

    }

    public LoggerVo( String status,String jobname, String message) {
        this.ext01 = jobname;
        this.status = status;
        this.date = new Date();
        if(message.length() > 2599){
            message = message.substring(0,2599);
        }

        if(jobname.equals("com.yegs.jindie.quartz.PurchaseJob")){
            this.jobname = "出库单任务调度";
        }
        else if(jobname.equals("com.yegs.jindie.service.PurchaseService")){
            this.jobname = "获取金蝶入库单数据";
        }
        else if(jobname.equals("com.yegs.jindie.service.AuthService")){
            this.jobname = "获取金蝶授权认证";
        }
        else if(jobname.equals("com.yegs.jindie.quartz.DeliveryJob")){
            this.jobname = "出库单任务调度";
        }
        else if(jobname.equals("com.yegs.jindie.service.DeliveryService")){
            this.jobname = "获取金蝶出库单数据";
        }
        else if(jobname.equals("com.yegs.jindie.quartz.InventoryJob")){
            this.jobname = "库存任务调度";
        }
        else if(jobname.equals("com.yegs.jindie.util.FTPTools")){
            this.jobname = "文件上传";
        }
        else{
            this.jobname = jobname;
        }

        this.message = message;
    }

    @Id
    @GeneratedValue(strategy= GenerationType.IDENTITY)
    private Long id;

    private String jobname;

    private String status;

    @JsonFormat(pattern ="yyyy-MM-dd HH:mm:ss.SSS")
    private Date date;

    @Column(length = 2599)
    private String message;
    private String ext01;
    private String ext02;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getJobname() {
        return jobname;
    }

    public void setJobname(String jobname) {
        this.jobname = jobname;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getExt01() {
        return ext01;
    }

    public void setExt01(String ext01) {
        this.ext01 = ext01;
    }

    public String getExt02() {
        return ext02;
    }

    public void setExt02(String ext02) {
        this.ext02 = ext02;
    }

    @Override
    public String toString() {
        return "LoggerVo{" +
                "id=" + id +
                ", jobname='" + jobname + '\'' +
                ", status='" + status + '\'' +
                ", date=" + date +
                ", message='" + message + '\'' +
                ", ext01='" + ext01 + '\'' +
                ", ext02='" + ext02 + '\'' +
                '}';
    }
}
